# core/models.py
from dataclasses import dataclass, field
from typing import List, Set, Dict, Any

@dataclass
class StatementLineage:
    op: str = ""
    tables: Set[str] = field(default_factory=set)
    target_tables: Set[str] = field(default_factory=set)
    source_tables: Set[str] = field(default_factory=set)
    columns_by_table: Dict[str, Set[str]] = field(default_factory=dict)
    ctes: Dict[str, Any] = field(default_factory=dict)
    raw_sql: str = ""

    # ✨ 新增：列到列血缘（源列 -> 目标列名/别名）
    # 例如：{"mysql7.dataview_trade.ddc_product_info.gross_profit_rate_max": {"毛利率"}}
    column_lineage: Dict[str, Set[str]] = field(default_factory=dict)

@dataclass
class LineageResult:
    statements: List[StatementLineage] = field(default_factory=list)
